from django.db import models
from django.contrib.auth.models import User, Group
from player.custom_field import BigIntegerField

# Create your models here.
class Player(models.Model):

    nickname = models.CharField("Nickname",max_length=50,unique=True)
    idr_score = BigIntegerField("Inflicted Damage score",blank=True,null=True)
    influence_score = BigIntegerField("Influence score",blank=True,null=True)

    hyp_rank = models.CharField("Hyperiums Rank",max_length=15,blank=True,null=True)
    
    def __repr__(self):
        return self.nickname
    def __str__(self):
        return self.nickname
        
class OCBPlayer(models.Model):
    
    player = models.ForeignKey(Player)
    user = models.ForeignKey(User)
    
    def __repr__(self):
        return self.player.nickname
    def __str__(self):
        return self.player.nickname

class Ally(Group):
    
    alliance_tag = models.CharField("Tag",unique=True,max_length=5)
    president = models.ForeignKey(Player, blank=True, null=True)
    nb_planets = models.IntegerField("Planet number", blank=True, null=True)

    def __repr__(self):
        return self.alliance_tag

    def __str__(self):
        return self.alliance_tag
